import Vue from 'vue'
import App from './App.vue'
import router from './router'
import FastClick from 'fastclick'
import axios from 'axios'
// import { Tabbar, TabItem } from 'mint-ui';
import 'lib-flexible'
import  '@/utils/permission'
import '@/utils/request'
// import{ getToken } from '@/utils/auth'
import 'styles/common.scss'
import * as filters from './filters/';
import Mint from 'mint-ui';
Vue.use(Mint);
// Vue.use(request);

// import Router from 'vue-router';
// const routerReplace = Router.prototype.replace;
// Router.prototype.replace = function replace(location) {
// return routerReplace .call(this, location).catch(error=> error)
// };




// axios.default.baseUrl = '/api';


FastClick.attach(document.body);
Vue.config.productionTip = false;
Vue.config.errorHandler = (err) => {
    console.error(err);
};

//注入api
import api from './api';
Vue.prototype.$api = api;

import store from './store/index';
Vue.prototype.$store = store;

// Vue.component(Tabbar.name, Tabbar);
// Vue.component(TabItem.name, TabItem);

// 注册过滤器
Object.keys(filters).forEach((key) => {
    Vue.filter(key, filters[key]);
});

// router.beforeEach(async (to, from, next) => {
//     const hasToken = getToken();
//     if (hasToken){
//         next();
//     }else if(to.path=='/login'){
//         next();
//     }else {
//         next({
//             replace:true,
//             path:'/login'
//         })
//     }


// })


new Vue({
    router,
    store,
    axios,
    
    render: h => h(App)
}).$mount('#app');
